package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class FollowedTagAddRequest extends Request {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6148176728748792793L;

	/**
	 * 标签ID
	 */
	private int tagId;

	private int userId;
	
	private String tagName;
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.tagId = requestInfo.getIntParameter(ApiUrlParamEnum.tagId.getParamName(), 0);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.tagName = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.tag.getParamName()));
		
		if(tagId == 0 && StringUtil.isEmpty(tagName)) {
			throw new RequestIllegalException("缺少标签id号或者标签名！");
		}
		if(userId == 0) {
			throw new RequestIllegalException("缺少用户id号!");
		}
		
	}
	
	public int getTagId() {
		return tagId;
	}

	public void setTagId(int tagId) {
		this.tagId = tagId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}
	
	public void setTagName(String tagName) {
		this.tagName = tagName;
	}
	
	public String getTagName() {
		return this.tagName;
	}

}
